package day10;

//本类是用来测试多态的入门演示demo
public class Test04 {
    public static void main(String[] args) {
        Animal1 a = new Animal1();
        Cat c = new Cat();
        Dog d = new Dog();
        a.eat();
        c.eat();
        d.eat();
        Animal1 a2 = new Cat();
        Animal1 a3 = new Dog();
//a2.eat();
//a3.eat();
//        a.jump();
//        a.run();
//父类不能使用子类的特有功能
    }
}

//1.创建父类
class Animal1 {
    //    3.创建普通方法
    public void eat() {
        System.out.println("吃东西");

    }
}

//2.1创建子类
class Cat extends Animal1 {
    //4.1创建重写的方法
    @Override
    public void eat() {
        System.out.println("小猫爱吃鱼干");

    }

    public void jump() {
        System.out.println("爱跳");
    }

}//2.2创建子类

class Dog extends Animal1 {
    //4.2创建重写的方法

    public void eat() {
        System.out.println("小狗爱吃骨头");

    }

    public void run() {
        System.out.println("爱跑");

    }
}
